package demoMod.stsconsole.enums;

import demoMod.stsconsole.map.MapNode;
import demoMod.stsconsole.rooms.*;

public enum MapRoomType {
    MONSTER,
    ELITE,
    EVENT,
    REST,
    SHOP,
    TREASURE
    ;
    public boolean canSetToThisType(MapNode currNode) {
        switch (this) {
            case MONSTER:
            case EVENT:
            default:
                return true;
            case ELITE:
                if (currNode.y <= 4) return false;
                for (MapNode node : currNode.prev) {
                    if (node.getRoomSymbol().equals("E")) return false;
                }
                for (MapNode node : currNode.next) {
                    if (node.getRoomSymbol().equals("E")) return false;
                }
                return true;
            case REST:
                if (currNode.y <= 4) return false;
                for (MapNode node : currNode.prev) {
                    if (node.getRoomSymbol().equals("R")) return false;
                }
                for (MapNode node : currNode.next) {
                    if (node.getRoomSymbol().equals("R")) return false;
                }
                return true;
            case SHOP:
                for (MapNode node : currNode.prev) {
                    if (node.getRoomSymbol().equals("$")) return false;
                }
                for (MapNode node : currNode.next) {
                    if (node.getRoomSymbol().equals("$")) return false;
                }
                return true;
            case TREASURE:
                for (MapNode node : currNode.prev) {
                    if (node.getRoomSymbol().equals("T")) return false;
                }
                for (MapNode node : currNode.next) {
                    if (node.getRoomSymbol().equals("T")) return false;
                }
                return true;
        }
    }

    public AbstractRoom getRoom() {
        switch (this) {
            case REST:
                return new RestRoom();
            case EVENT:
                return new EventRoom();
            case ELITE:
                return new MonsterRoomElite();
            case MONSTER:
            default:
                return new MonsterRoom();
            case SHOP:
                return new ShopRoom();
            case TREASURE:
                return new TreasureRoom();
        }
    }
}
